<%@page import="accessor.UserAccessor"%>
<%@page import="accessor.User"%>
<%@page import="java.util.List"%>
<%@include file="header.jsp" %>
<script>
    $(document).ready(function(){
         $(vmenu2).addClass('current');
    });
</script>
<%@include file="menubar/adminmenu.jsp" %>
<div class="break_line"></div>
<div class="break_line"></div>

<div id="content">
    <div id="title_content">LIST USERS</div>
    <% if (request.getSession().getAttribute("mess") != "" && request.getSession().getAttribute("mess") != null) {%>
    <div class="affiche_erreur" style="width: 475px;margin-left: 8px;">
        <%
        //request.getSession().setAttribute("mess","");
            out.println(request.getSession().getAttribute("mess"));
        %>
    </div>
    <%}%>
    <form method="POST" action="#" onsubmit="return go();">
        <%
            UserAccessor userAccessor = new UserAccessor();
            List<User> users = userAccessor.getAllUser();
        %>
        <table class="list" width="100%">
            <thead>
                <tr>
                    <th>UserID</th>
                    <th>EMAIL</th>
                    <th>DEPARTMENT</th>
                    <th>LAST LOGIN</th>
                    <th colspan="3" align="center">Action</th>
                </tr>
            </thead>
            <tbody>
                <% for (User user : users) {%>
                <tr>
                    <td><%= user.getUserID()%></td>
                    <td><%= user.getEmail()%></td>
                    <td><%= user.getDepartmentName()%></td>
                    <td><%= user.getLastLoginDate()%></td>
                    <% if (user.getActive() == 1) {%>
                    <td width="30px"><a class="confirm_delete" href="../deactive_user?userID=<%= user.getUserID()%>"><img src="../assets/css/backend/images/active.png" alt="active" title="active"/></a></td>
                            <% } else {%>
                    <td width="30px"><a href="../active_user?userID=<%= user.getUserID()%>"><img src="../assets/css/backend/images/deactivate.gif" alt="deactivate" title="deactivate"/></a></td>
                            <% }%>
                    <td width="30px"><a href="update_user.jsp?userID=<%= user.getUserID()%>"><img src="../assets/css/backend/images/modifier.png" alt="modifier"/></a></td>
                    <td width="30px"><a onclick="return confirm('Are you sure? ')" href="../delete_user?userID=<%= user.getUserID()%>"><img src="../assets/css/backend/images/supprimer.png" alt="supprimer"/></a></td>
                </tr>
                <% }%>

            </tbody>
        </table>
        <div class="delete_button">
            <table width="100%">
                <tr>
                    <td align="left" width="200px" ></td>
                    <td align="right"></td>
                </tr>
            </table>
        </div>
    </form>
</div>
<!--END content-->
<%@include file="footer.jsp" %>